<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商家登录 - 灵犀智苑</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
        }

        :root {
            --primary: #4361ee;
            --primary-light: #5e72e4;
            --secondary: #4cc9f0;
            --accent: #e67e22;
            --light: #ecf0f1;
            --dark: #34495e;
            --darker: #2c3e50;
            --text: #2c3e50;
            --text-light: #7f8c8d;
            --glass: rgba(255, 255, 255, 0.2);
            --border: rgba(255, 255, 255, 0.3);
            --shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
            --transition: all 0.3s ease;
            --success: #28a745;
            --warning: #ffc107;
            --info: #17a2b8;
            --danger: #dc3545;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #e4e7eb 100%);
            color: var(--text);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
            position: relative;
        }

        .background-blur {
            position: fixed;
            top: -50px;
            left: -50px;
            right: -50px;
            bottom: -50px;
            background: url('');
            filter: blur(40px);
            z-index: -1;
        }

        .glass {
            background: var(--glass);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--border);
            box-shadow: var(--shadow);
            border-radius: 20px;
            overflow: hidden;
        }

        /* 登录/注册表单容器 */
        .auth-container {
            width: 90%;
            max-width: 450px;
            padding: 2.5rem;
            text-align: center;
            position: relative;
            z-index: 1;
        }

        .auth-logo {
            font-size: 2.5rem;
            font-weight: 700;
            background: linear-gradient(90deg, var(--primary), var(--accent));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            margin-bottom: 1.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
        }

        .auth-logo-icon {
            margin-right: 10px;
            animation: float 3s ease-in-out infinite;
        }

        @keyframes float {
            0% { transform: translateY(0px); }
            50% { transform: translateY(-10px); }
            100% { transform: translateY(0px); }
        }

        /* 修正标题位置 */
        .auth-title {
            font-size: 1.8rem;
            color: var(--darker);
            margin: 0 auto 2rem; /* 添加自动外边距实现居中 */
            text-align: center; /* 确保文本居中 */
            display: block; /* 确保宽度自适应 */
            width: 100%; /* 确保宽度100% */
            position: relative;
            padding-top: 10px;
            animation: fadeInDown 0.6s ease-out;
        }

        @keyframes fadeInDown {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .form-group {
            margin-bottom: 1.5rem;
            text-align: left;
            animation: fadeInUp 0.6s ease-out;
            animation-delay: 0.2s;
            animation-fill-mode: both;
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: 500;
            color: var(--darker);
        }

        .form-control {
            width: 100%;
            padding: 0.8rem 1rem;
            border: 1px solid #ddd;
            border-radius: 10px;
            font-size: 1rem;
            transition: var(--transition);
        }

        .form-control:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
        }

        .btn-submit {
            background: linear-gradient(90deg, var(--primary), var(--accent));
            color: white;
            padding: 1rem 2rem;
            border: none;
            border-radius: 10px;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            width: 100%;
            transition: var(--transition);
            margin-top: 1rem;
            animation: fadeInUp 0.6s ease-out;
            animation-delay: 0.4s;
            animation-fill-mode: both;
        }

        .btn-submit:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(67, 97, 238, 0.4);
        }

        .auth-link {
            display: block;
            margin-top: 1.5rem;
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
            transition: var(--transition);
            animation: fadeInUp 0.6s ease-out;
            animation-delay: 0.5s;
            animation-fill-mode: both;
        }

        .auth-link:hover {
            color: var(--primary-light);
            text-decoration: underline;
        }

        .error-message {
            color: var(--danger);
            font-size: 0.85rem;
            margin-top: 0.3rem;
            display: none;
            animation: fadeIn 0.3s ease-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        /* 添加响应式调整 */
        @media (max-width: 500px) {
            .auth-container {
                padding: 1.8rem;
            }
            
            .auth-logo {
                font-size: 2rem;
            }
            
            .auth-title {
                font-size: 1.6rem;
                margin-bottom: 1.5rem;
            }
        }
    </style>
</head>
<body>
    <div class="background-blur"></div>
    
    <div class="auth-container glass">
        <div class="auth-logo">
            <span class="auth-logo-icon">✨</span>
            <span>灵犀智苑</span>
        </div>
        <h1 class="auth-title">商家登录</h1>
        
        <form id="login-form">
            <div class="form-group">
                <label for="login-email">电子邮箱 *</label>
                <input type="email" id="login-email" class="form-control" placeholder="请输入您的电子邮箱">
                <div class="error-message" id="email-error">请输入有效的电子邮箱</div>
            </div>
            
            <div class="form-group">
                <label for="login-password">密码 *</label>
                <input type="password" id="login-password" class="form-control" placeholder="请输入密码">
                <div class="error-message" id="password-error">密码不能为空</div>
            </div>
            
            <button type="submit" class="btn-submit">登录</button>
            
            <a href="merchant_register.html" class="auth-link">还没有账号？立即注册</a>
        </form>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            const loginForm = document.getElementById('login-form');
            const loginEmailInput = document.getElementById('login-email');
            const loginPasswordInput = document.getElementById('login-password');

            const emailError = document.getElementById('email-error');
            const passwordError = document.getElementById('password-error');

            function validateEmail(email) {
                const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
                return re.test(String(email).toLowerCase());
            }

            loginForm.addEventListener('submit', function(e) {
                e.preventDefault();
                let isValid = true;

                // Reset errors
                emailError.style.display = 'none';
                passwordError.style.display = 'none';

                // Validate Email
                if (!validateEmail(loginEmailInput.value.trim())) {
                    emailError.style.display = 'block';
                    isValid = false;
                }

                // Validate Password
                if (loginPasswordInput.value.trim() === '') {
                    passwordError.style.display = 'block';
                    isValid = false;
                }

                if (isValid) {
                    // 模拟登录成功后存储信息到 localStorage
                    localStorage.setItem('loggedInMerchantName', '示例商家'); // 这里使用一个示例商家名称
                    localStorage.setItem('loggedInMerchantEmail', loginEmailInput.value.trim()); // 存储登录的邮箱

                    // 添加成功动画
                    const submitBtn = document.querySelector('.btn-submit');
                    submitBtn.innerHTML = '<i class="fas fa-check"></i> 登录成功';
                    submitBtn.style.background = 'linear-gradient(90deg, var(--success), var(--primary))';
                    
                    setTimeout(() => {
                        alert('登录成功！即将跳转到商家中心。');
                        window.location.href = 'merchant.html'; // 登录成功后跳转到商家中心仪表盘
                    }, 1000);
                }
            });
            
            // 添加输入框焦点动画
            const inputs = document.querySelectorAll('.form-control');
            inputs.forEach(input => {
                input.addEventListener('focus', function() {
                    this.parentElement.style.transform = 'scale(1.01)';
                });
                
                input.addEventListener('blur', function() {
                    this.parentElement.style.transform = 'scale(1)';
                });
            });
        });
    </script>
</body>
</html>merchant_login.html